from django.db import models

# Create your models here.

class User(models.Model):
	# 用户表格字段有ID、username、role、password
	id =models.AutoField(primary_key=True)
	username = models.CharField(max_length=20)
	role = models.IntegerField()
	password = models.CharField(max_length=20)
	
class DeviceInfo(models.Model):
	id = models.AutoField(primary_key=True)
	device_name = models.CharField(max_length=20)
	device_type = models.CharField(max_length=20)
	device_platform = models.CharField(max_length=20)
	cpu_type = models.CharField(max_length=20)
	mem_num = models.IntegerField()
	version = models.CharField(max_length=10)
	level = models.CharField(max_length=8)
	hot = models.BooleanField()
	borrow = models.BooleanField()
	state = models.BooleanField()
	
	# class Meta:
	# 	permissions=(
	# 		('view_deviceinfo','Can view device_info '),
	# 		('change_deviceinfo','Can change the status deviceinfo'),
	# 	)


class  Certificate(models.Model):
	id = models.AutoField(primary_key=True)
	# borrow = models.BooleanField()
	borrow_time = models.DateTimeField(auto_now=True)
	revert_time = models.DateTimeField(auto_now=True)
	over_time = models.DateTimeField(auto_now=True)
	user = models.ForeignKey(to=User,on_delete=models.CASCADE)
	device = models.ForeignKey(to=DeviceInfo,on_delete=models.CASCADE)
	


